User:Eric Martz/Sandbox 3

Scenes
Opening the proposed Evolutionary Conservation section below the molecule would automatically color all chains by ConSurf, and spacefill them. Checkboxes in this section, one per chain, would be checked when the section is first opened. Unchecking a given chain would render it as a gray backbone (as in ConSurf). Ligands will be ball and stick, with dot surfaces, colored by element (as in ConSurf; oops, forgot to do the sulfates in some scenes). Here, for demonstration purposes, are 5 of the 16 possible scenes that 4-chain-checkboxes could generate:
 * ConSurf color all 4 chains (2 alphas, A and C, and 2 betas, B and D, in 2HHD).
 * ConSurf color only chains A and B (one alpha, one beta)
 * ConSurf color only chains A and C (both alphas)
 * ConSurf color only chain A
 * All chains unchecked

Button Tests
 if (consurf_A!=0); select:A; spacefill off;color translucent -1; consurf_A = 0;javascript "document.getElementById('jmb_A').value='A [ ]'"; else; select:A; spacefill on; color opaque;consurf_A = 1;javascript "document.getElementById('jmb_A').value='A [x]';"; endif; A [ ] jmb_A  Lower case x so it doesn't look like chain X. Two spaces in empty [ ]. Uses document.getElementById('jmb_A').value='...'. Works in


 * Internet Explorer 7/Windows XP
 * Internet Explorer 6/Windows 98
 * Firefox2/Windows 98/Windows XP
 * Firefox2/OSX
 * Safari/OSX (mouse movement needed to get the text change, else button label is always one step behind).

 if (~B!=0); select:B; spacefill off;color translucent -1; ~B = 0;javascript "bB.value='B [ ]'"; else; select:B; spacefill on; color opaque;~B = 1;javascript "bB.value='B [x]'"; endif; B [ ] bB  Uses bB.value='...'. Firefox: javascript error, bB is not defined, so no button text change in Firefox. Firefox every second click ignored unless mouseout between clicks. Works in Safari/OSX and Internet Explorer 6/7/Windows.

Checkmark: &#10003; but if it is used in the button text label, the previous characters don't appear. Could maybe use a button label &#10003;A instead of A[&#10003;], but haven't tested it. And in Internet Explorer 7, this "checkmark" appears as two horizontal bars. Not worth pursuing, I think. (Similarly, I often see problems with greek letters, so it is better to spell them out in English than to try to show the actual greek letter.)

User Interface & Color Key
To keep the user interface simple in Proteopedia, at least to start with, I propose that the only controls will be one checkbox per chain to ConSurf-color+spacefill each chain or not. The color key will not be interactive (unlike in ConSurf). Clicking the link Complete results at ConSurf will provide a path to the display in FirstGlance in Jmol with many more options.

Below are non-interactive mockups just to suggest the look for a user interface that would be an additional expandable block beneath the molecule.
 * Links do not work.
 * When a chain is "checked" [x], it will be colored by conservation, and spacefill it. When unchecked, that chain will become a gray backbone trace.
 * The link to Explanation would go to a Proteopedia page of explanation. It might be a revised version of Conservation, Evolutionary.

Before expanding this section, it could look like this:

After expanding, it could look like this (using buttons):

Scripts
When the Evolutionary Conservation block is expanded, a master script is run that colors and spacefills all chains.

The scripts below are designed to work both for single-model X-ray files, and for NMR Ensembles of Models. In the latter, the scripts show only model 1 for ConSurf scenes (frame 1.1).

Changing a Checkbox
After a chain checkbox (in the expanded Evolutionary Conservation block) is changed, the currently checked chains are put into this script:

 select protein spacefill off select (:a,:c) # LIST OF CHECKED CHAINS spacefill 

The gray backbones for all chains are always rendered, but are hidden within spacefilled atoms, when a chain is spacefilled. Once set, the colors never change. Although the backbones are gray, the atoms are ConSurf-colored. All a checkbox needs to do is spacefill the appropriate set of chains. The colors remain.

Design Goals for ConSurf Scripts
ConSurfDB generates one script per chain. Proteopedia will generate, from these, a single consolidated script for each PDB entry. The initial view, shown automatically when the Evolutionary Conservation block is expanded, will be produced by the consolidated script, and will apply ConSurf colors to all chains concurrently. An example is the ConSurf color all 4 chains green linked scene above. The ConSurf team does not show such an all-chain view for hetero-oligomers because the conservation level colors are relative, and do not have the same quantitative conservation level meanings in sequence-different chains. Proteopedia will explain this, but will provide an all-chain view as the initial view. Individual chains can then be de-colored with the checkboxes.

In order to have to generate just a single ConSurf script per PDB file, that single consolidated script must serve two purposes. It must generate the desired initial view when the Evolutionary Conservation block is expanded, and it must serve the SAT Colors dialog, enabling the user to apply ConSurf colors to any selected protein moiety.

Note that (possibly) in contrast to the scripts at ConSurfDB, the defined Jmol variables ~con1, ~con2, ... ~con10 now each begin with a tilde (~). This is the recommended practice for such variables in Jmol, to avoid possible conflicts. Once these are defined, the scripts avoid re-defining them when called again, to save execution time.

Top Level ConSurf Script
This is the script sent to Jmol when the Evolutionary Conservation block is expanded.

 select protein define ~consurf_to_do selected consurf_initial_scene = true script "/wiki/ConSurf/hh/2hhd_consurf.spt"; 

consurf_color_levels.spt
This script is called by the [PDB code]_consurf.spt. The purpose of this script is to color all, or any subset, of protein atoms according to ConSurf.

This script is "constant": the same for all PDB entries.

A big advantage of this script is that it sets the ConSurf color RGB values. If any ever need to be changed, only this one script needs changing.

This script requires that the atom subset term ~consurf_to_color be defined beforehand. It also requires that the consurf level terms ~con## have been defined beforehand.

 select ~consurf_to_color color yellow
 * 1) Any protein atoms not assigned a consurf level, e.g. short peptides not processed by consurf,
 * 2) will remain the following color. Example: chain P in 2VAA.

select ~consurf_to_color and ~con10 color [255,255,150] select ~consurf_to_color and ~con9 color [160,37,96] select ~consurf_to_color and ~con8 color [240,125,171] select ~consurf_to_color and ~con7 color [250,201,222] select ~consurf_to_color and ~con6 color [252,237,244] select ~consurf_to_color and ~con5 color [255,255,255] select ~consurf_to_color and ~con4 color [234,255,255] select ~consurf_to_color and ~con3 color [215,255,255] select ~consurf_to_color and ~con2 color [140,255,255] select ~consurf_to_color and ~con1 color [16,200,209] 
 * 1) Each consurf level is now colored with the standard consurf colors.

consurf_prescript.spt
This script is constant. That is, it is the same for all PDB files. It is required by [PDB code]_consurf.spt.

 if (consurf_initial_scene)

# Hide molecule script "/wiki/scripts/allRenderingsOff.spt";

# Render ligands select hetero and not water spacefill 0.5 wireframe 0.3 color cpk dots

endif </tt>

consurf_postscript.spt
This script is constant. That is, it is the same for all PDB files. It is required by [PDB code]_consurf.spt.

 if (consurf_initial_scene)

# Spacefill all protein. select protein define ~consurf_to_color selected # color all protein spacefill

# Give all protein a carbon-colored backbone. backbone 0.4 color backbone [xc8c8c8]

# Show nucleic as phosphorus-colored cartoon. select nucleic cartoon color cpk

endif

script "/wiki/scripts/consurf_color_levels.spt";
 * 1) Unconditionally color the ~consurf_to_color atoms.

</tt>

2hhd_consurf.spt

 * 1) This script defines ~con1, ~con2, ... ~con10, the atoms in each consurf level, unless they have already been defined in a previous execution of this script (see consurf_levels_defined). The amino acids per color grade are combined into each ~con## term for all chains as shown in the example script below. These terms, ~con##, are used in consurf_color_levels.spt.
 * 2) This script applies ConSurf colors to the protein atoms included in ~consurf_to_color (which must therefore be defined before calling this script).
 * 3) This script produces the Evolutionary Conservation initial scene only if consurf_initial_scene is true. Therefore, consurf_initial_scene must be set before calling this script.
 * 4) Wherever possible, this script calls other scripts to separate commands that are not PDB-ID specific, so they can be maintained separately.

 script "/wiki/scripts/consurf_prescript.spt";

if (!consurf_levels_defined) define ~con10 none select PHE71, PHE85, PHE118 select selected and :B select selected or ~con10 define ~con10 selected select PHE71, PHE85, PHE118 select selected and :D select selected or ~con10 define ~con10 selected
 * 1) If consurf_levels_defined is undefined, it is false.

define ~con9 none select LYS7, LYS16, GLU27, ARG31, PHE33, PRO37, THR39, LYS40, THR41, PHE43 select selected or SER52, HIS58, GLY59, LYS61, VAL62, ALA65, ALA69, LEU83, SER84 select selected or HIS87, ALA88, LEU91, ARG92, VAL93, ASP94, PRO95, ASN97, PHE98 select selected or LEU101, HIS122, SER124, ASP126, LYS127, VAL132, LEU136 select selected or LYS139, TYR140, ARG141 select selected and :A select selected or ~con9 define ~con9 selected select VAL1, GLU7, LYS8, TRP15, GLY24, ARG30, LEU32, VAL34, TYR35, PRO36, TRP37 select selected or THR38, ARG40, PHE42, PHE45, GLY46, SER49, ALA53, ASN57, VAL60 select selected or ALA62, HIS63, GLY64, LYS66, VAL67, ASP79, LEU81, LYS82, LEU88 select selected or SER89, GLU90, HIS92, LEU96, VAL98, PRO100, ASN102, PHE103 select selected or LEU106, PHE122, GLN127, LYS132, VAL137, ALA140, TYR145 select selected or HIS146 select selected and :B select selected or ~con9 define ~con9 selected select LYS7, LYS16, GLU27, ARG31, PHE33, PRO37, THR39, LYS40, THR41, PHE43 select selected or SER52, HIS58, GLY59, LYS61, VAL62, ALA65, ALA69, LEU83, SER84 select selected or HIS87, ALA88, LEU91, ARG92, VAL93, ASP94, PRO95, ASN97, PHE98 select selected or LEU101, HIS122, SER124, ASP126, LYS127, VAL132, LEU136 select selected or LYS139, TYR140, ARG141 select selected and :C select selected or ~con9 define ~con9 selected select VAL1, GLU7, LYS8, TRP15, GLY24, ARG30, LEU32, VAL34, TYR35, PRO36, TRP37 select selected or THR38, ARG40, PHE42, PHE45, GLY46, SER49, ALA53, ASN57, VAL60 select selected or ALA62, HIS63, GLY64, LYS66, VAL67, ASP79, LEU81, LYS82, LEU88 select selected or SER89, GLU90, HIS92, LEU96, VAL98, PRO100, ASN102, PHE103 select selected or LEU106, PHE122, GLN127, LYS132, VAL137, ALA140, TYR145 select selected or HIS146 select selected and :D select selected or ~con9 define ~con9 selected

define ~con8 none select VAL1, LEU2, SER3, ASP6, GLY25, LEU29, TYR42, HIS45, PHE46, ASP47, GLY51 select selected or GLN54, ASP74, ASP85, LEU86, VAL96, LYS99, HIS112, THR118 select selected or PRO119, ALA123, PHE128, VAL135 select selected and :A select selected or ~con8 define ~con8 selected select VAL18, LEU28, GLN39, PHE41, ASP47, LEU48, LEU91, CYS93, ASP94, HIS97 select selected or ASP99, GLU101, LEU105, GLY107, ASN108, ALA115, ALA129, ALA138 select selected or LEU141 select selected and :B select selected or ~con8 define ~con8 selected select VAL1, LEU2, SER3, ASP6, GLY25, LEU29, TYR42, HIS45, PHE46, ASP47, GLY51 select selected or GLN54, ASP74, ASP85, LEU86, VAL96, LYS99, HIS112, THR118 select selected or PRO119, ALA123, PHE128, VAL135 select selected and :C select selected or ~con8 define ~con8 selected select VAL18, LEU28, GLN39, PHE41, ASP47, LEU48, LEU91, CYS93, ASP94, HIS97 select selected or ASP99, GLU101, LEU105, GLY107, ASN108, ALA115, ALA129, ALA138 select selected or LEU141 select selected and :D select selected or ~con8 define ~con8 selected

define ~con7 none select MET32, LEU66, ASP75, ALA79, LEU80, HIS103, VAL107, THR108, ALA110, PHE117 select selected or THR137, SER138 select selected and :A select selected or ~con7 define ~con7 selected select VAL11, LYS17, GLU26, ALA27, GLY29, LEU31, THR84, LYS95, GLN131, VAL134 select selected and :B select selected or ~con7 define ~con7 selected select MET32, LEU66, ASP75, ALA79, LEU80, HIS103, VAL107, THR108, ALA110, PHE117 select selected or THR137, SER138 select selected and :C select selected or ~con7 define ~con7 selected select VAL11, LYS17, GLU26, ALA27, GLY29, LEU31, THR84, LYS95, GLN131, VAL134 select selected and :D select selected or ~con7 define ~con7 selected

define ~con6 none select TRP14, ALA28, PRO44, LYS60, HIS72, SER81, LYS90, SER102, CYS104, SER133 select selected and :A select selected or ~con6 define ~con6 selected select HIS2, LEU3, VAL33, ALA70, GLY74, HIS77, ALA86, VAL113, LEU114, THR123 select selected or PRO124, LYS144 select selected and :B select selected or ~con6 define ~con6 selected select TRP14, ALA28, PRO44, LYS60, HIS72, SER81, LYS90, SER102, CYS104, SER133 select selected and :C select selected or ~con6 define ~con6 selected select HIS2, LEU3, VAL33, ALA70, GLY74, HIS77, ALA86, VAL113, LEU114, THR123 select selected or PRO124, LYS144 select selected and :D select selected or ~con6 define ~con6 selected

define ~con5 none select VAL17, ALA26, PHE36, LYS56, VAL70, LEU100, LEU106, VAL121 select selected and :A select selected or ~con5 define ~con5 selected select THR4, ASN19, LYS65, ASN80, VAL111, ALA128, VAL133, GLY136, HIS143 select selected and :B select selected or ~con5 define ~con5 selected select VAL17, ALA26, PHE36, LYS56, VAL70, LEU100, LEU106, VAL121 select selected and :C select selected or ~con5 define ~con5 selected select THR4, ASN19, LYS65, ASN80, VAL111, ALA128, VAL133, GLY136, HIS143 select selected and :D select selected or ~con5 define ~con5 selected

define ~con4 none select HIS20, ALA21, LEU48, SER49, MET76, PRO77, LEU109, ALA120 select selected and :A select selected or ~con4 define ~con4 selected select GLU6, THR50, VAL54, LYS59, LEU68, SER72, HIS117 select selected and :B select selected or ~con4 define ~con4 selected select HIS20, ALA21, LEU48, SER49, MET76, PRO77, LEU109, ALA120 select selected and :C select selected or ~con4 define ~con4 selected select GLU6, THR50, VAL54, LYS59, LEU68, SER72, HIS117 select selected and :D select selected or ~con4 define ~con4 selected

define ~con3 none select ASN9, VAL10, LYS11, SER35, THR38, HIS50, VAL55, HIS89, LEU125, ALA130 select selected or THR134 select selected and :A select selected or ~con3 define ~con3 selected select VAL20, MET55, LYS61, VAL109, ALA142 select selected and :B select selected or ~con3 define ~con3 selected select ASN9, VAL10, LYS11, SER35, THR38, HIS50, VAL55, HIS89, LEU125, ALA130 select selected or THR134 select selected and :C select selected or ~con3 define ~con3 selected select VAL20, MET55, LYS61, VAL109, ALA142 select selected and :D select selected or ~con3 define ~con3 selected

define ~con2 none select GLU30, ALA53, THR67, ALA71, ALA82, LEU105, PRO114, LEU129 select selected and :A select selected or ~con2 define ~con2 selected select GLY25, LEU75, ALA76, LYS120, GLU121 select selected and :B select selected or ~con2 define ~con2 selected select GLU30, ALA53, THR67, ALA71, ALA82, LEU105, PRO114, LEU129 select selected and :C select selected or ~con2 define ~con2 selected select GLY25, LEU75, ALA76, LYS120, GLU121 select selected and :D select selected or ~con2 define ~con2 selected

define ~con1 none select PRO4, ALA5, THR8, ALA12, ALA13, GLY15, GLY18, ALA19, GLY22, GLU23, TYR24 select selected or LEU34, GLY57, ALA63, ASP64, ASN68, VAL73, ASN78, ALA111 select selected or LEU113, ALA115, GLU116, SER131 select selected and :A select selected or ~con1 define ~con1 selected select PRO5, SER9, ALA10, THR12, ALA13, LEU14, GLY16, ASP21, GLU22, VAL23, GLU43 select selected or SER44, PRO51, ASP52, GLY56, PRO58, GLY69, ASP73, LEU78, GLY83 select selected or THR87, ARG104, LEU110, CYS112, HIS116, GLY119, PRO125, VAL126 select selected or TYR130, ALA135, ASN139 select selected and :B select selected or ~con1 define ~con1 selected select PRO4, ALA5, THR8, ALA12, ALA13, GLY15, GLY18, ALA19, GLY22, GLU23, TYR24 select selected or LEU34, GLY57, ALA63, ASP64, ASN68, VAL73, ASN78, ALA111 select selected or LEU113, ALA115, GLU116, SER131 select selected and :C select selected or ~con1 define ~con1 selected select PRO5, SER9, ALA10, THR12, ALA13, LEU14, GLY16, ASP21, GLU22, VAL23, GLU43 select selected or SER44, PRO51, ASP52, GLY56, PRO58, GLY69, ASP73, LEU78, GLY83 select selected or THR87, ARG104, LEU110, CYS112, HIS116, GLY119, PRO125, VAL126 select selected or TYR130, ALA135, ASN139 select selected and :D select selected or ~con1 define ~con1 selected

consurf_levels_defined = true

endif # if (!consurf_levels_defined)

script "/wiki/scripts/consurf_postscript.spt";

</tt>

SAT Color by Conservation Script
It is proposed that the Color dialog in the SAT will include a new option to color by Evolutionary Conservation. Here is the script proposed to accomplish this.

The script below works regardless of whether the conservation levels (~con##) have been previously defined; that is, it works regardless of whether the Evolutionary Conservation block has previously been opened.

This script is not "constant". It must be generated per PDB code (see last line of script below).


 * 1) This script applies conservation colors to the previously selected (currently selected) atoms.

select selected and protein
 * 1) In case the user selected some non-protein atoms:

define ~consurf_to_color selected

consurf_initial_scene = false

script "/wiki/ConSurf/hh/2hhd_consurf.spt"; </tt>